<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class AddSomeindexToUserFollowAndUserUserCertOcrs extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::table('user_cert_ocrs', function (Blueprint $table) {
            $table->index('valid_date_end', 'valid_date_end');
        });
        Schema::table('user_follows', function (Blueprint $table) {
            $table->index('created_at', 'user_follows_created_at');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        if(Schema::hasTable('user_cert_ocrs')){
            Schema::table('user_cert_ocrs', function (Blueprint $table) {
                $table->dropIndex('valid_date_end');
            });
        }
        if(Schema::hasTable('user_follows')){
            Schema::table('user_follows', function (Blueprint $table) {
                $table->dropIndex('user_follows_created_at');
            });
        }
    }
}
